package cloud.maque.admin.controller;

import cloud.maque.admin.annotations.TenantId;
import cloud.maque.admin.annotations.TenantQuery;
import cloud.maque.admin.domain.entity.MqEnumGroup;
import cloud.maque.admin.service.MqEnumGroupService;
import cloud.maque.framework.common.request.PaginateDataResquest;
import cloud.maque.framework.common.response.ResponseBodyVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 字典组接口
 *
 * @author zhuyf
 * @date 2023/3/17 20:57
 */
@RestController
@RequestMapping(value = "/enum/group")
@Api(tags = "运维-字典组接口")
public class EnumGroupController {

    @Autowired
    MqEnumGroupService groupService;


    @PostMapping("/list")
    @ApiOperation(value = "字典组接口查询")
    @TenantQuery
    public ResponseBodyVo<PageInfo<MqEnumGroup>> page(@RequestBody @ApiParam("查询内容") PaginateDataResquest<MqEnumGroup> pageReq) {
        return ResponseBodyVo.Success(groupService.page(pageReq));
    }

    @GetMapping("/detail")
    @ApiOperation(value = "组详情")
    public ResponseBodyVo<MqEnumGroup> Detail(@RequestParam("id") String id) {
        return ResponseBodyVo.Success(groupService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增组")
    public ResponseBodyVo<MqEnumGroup> Save(@RequestBody @ApiParam("组内容") MqEnumGroup group) {
        groupService.saveOrUpdate(group);
        return ResponseBodyVo.Success(group);
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "删除部门")
    @TenantQuery
    public ResponseBodyVo<Boolean> Delete(@RequestParam("id") String groupId, @TenantId String tenantId) {
        return ResponseBodyVo.Success(groupService.delete(groupId,tenantId));
    }


}
